home *** CD-ROM | disk | FTP | other *** search
/ An Invitation to the Roland World of Music / Roland - An Invitation To The Roland World Of Music.bin / specs / hexkey.txt < prev    next >
Text File  |  1994-06-03  |  6KB  |  124 lines

  1. WHAT THE HEX?
  2. ============================================================
  3. ** This is a reprint from KEYBOARD magazine's February 1994 issue.**
  4.  
  5. MIDI messages can be notated numerically in one of three ways: binary, decimal, or hexadecimal. The 
  6. method the microprocessors in your MIDI equipment prefers is binary, in which each of the eight bits in a 
  7. data byte is represented by either a 0 or a 1. You, though you may not realize it yet, prefer to use the 
  8. decimal system, in which each of your ten fingers is represented by an Arabic numeral, the familiar 0 
  9. though 9. Hexadecimal notation (or "hex" as it is affectionately known), makes working with MIDI 
  10. messages easier than either of the other two systems. Hex is base 16, with the rightmost column being the 
  11. "ones" column, and the column to the left being the "16s". Our decimal system only has 10 symbols for 
  12. representing numbers, but hex must have 16. To accommodate these six unrepresented values, we use the 
  13. letters A through F to represent the values from 10 through 15 decimal. A value of 16 appears in hex as 
  14. 10. (Some publications use an "H" after a hex number, to make it easy to tell the difference between 10 in 
  15. decimal and 10H, which would be 16 in decimal.)
  16.  
  17. Contrary to popular belief, the engineers who invented the hex system did not have eight fingers on each 
  18. hand. They did, however, have plenty of eight-bit bytes in binary to worry about. Since four digits of 
  19. binary can represent a total of 16 different values, we can quickly translate an eight-digit binary number 
  20. into a two-digit hex number. It's easier to recognize status bytes and MIDI channels when they are in hex 
  21. notation; consequently, it's easier to keep track of MIDI messages when inserting them in a sequencer 
  22. track or programming your Sound Canvas in Micro Edit mode, which displays all parameters in hex. 
  23. MIDI system-exclusive messages contain hexadecimal respresentations of a given instrument's internal 
  24. parameter settings. 
  25.  
  26. The Sound Canvas's sys-ex messages are divided into three sections: header, body, and end. The header is 
  27. virtually identical for most of the sys-ex messages you'll use with the Sound Canvas. It simply identifies 
  28. this message as sys-ex data for a Roland GS instrument. 
  29.  
  30. F0    Begin sys-ex    
  31. 41    Roland ID    
  32. 10    Device ID    
  33. 42    GS Model ID    
  34. 12    Data Set Command    
  35.  
  36. The body consists of a three-byte address, any number (up to 256) of data bytes, and the infamous Roland 
  37. checksum. Each editable parameter in the Sound Canvas has its own sys-ex address. This allows you to 
  38. send a sys-ex message to a specific address without bothering the neighboring parameters. Look for the 
  39. Parameter Base Address near the back of your Sound Canvas manual, then find the table labeled Patch 
  40. Parameters for the addresses used in these examples.
  41.  
  42. For our first example, we'll change the reverb from the Hall 2 default setting to delay. Under Patch 
  43. Parameters, Reverb Macro is listed next to the address 40 01 30. We enter those numbers as our three-byte 
  44. address.
  45.  
  46. 40    \
  47. 01  Address
  48. 30    /    
  49.  
  50. The address is a starting point for the data bytes to enter memory. The first data byte is entered at that 
  51. address, and the remaining data bytes automatically flow to the following address locations. For Reverb 
  52. Macro, the manual indicates there are eight choices, of which delay is number 06, so 06 becomes our first 
  53. and only data byte.
  54.  
  55. 06    Data    
  56.  
  57. Next, we need to compute a checksum for this message. The checksum is used to protect your Sound 
  58. Canvas from receiving corrupted data by ensuring that the address and data bytes follow a precise 
  59. mathematical formula. Corruption is usually not a problem when creating small messages, as in these 
  60. examples, but can be when one missing byte in a bulk dump can ruin a dozen of your favorite patches! 
  61. Here's a simple translation of the checksum formula:
  62.  
  63. 80 - (sum of address bytes + sum of data bytes) = Checksum
  64.  
  65. If the sum of the address and data bytes is greater than 80 (hex), the result will be a negative checksum. In 
  66. that case, subtract 80 from the address and data sum as often as necessary until the sum is less than 80, so 
  67. that the subtraction that computes the checksum yields a positive result. For our example, we have:
  68.  
  69. 80 - (40 + 01 + 30 + 06) = Checksum
  70. 80 - 77 = Checksum
  71. 09 = Checksum
  72.  
  73. But hypothetically, if the sum of the address and data bytes had been greater than 80 (hex):
  74.  
  75. 80 - (80 + 40 + 01 + 40 + 06) = Checksum
  76. 80 - 107 = Checksum (negative, so subtract 80)
  77. 80 - (107 - 80) = Checksum (still negative, so subtract 80 again)
  78. 80 - (87 - 80) = Checksum (positive)
  79. 79 = Checksum
  80.  
  81. So our body now becomes:
  82. 40    \
  83. 01  Address
  84. 30    /    
  85. 06   Data    
  86. 09   Checksum    
  87.  
  88. If you're new to hex, you may be confused to see an equation like 80 - 77 = 09. You may find it easier to 
  89. convert all the values to decimal, perform the subtraction, and then convert back. In this case, 128 (equal 
  90. to 80 hex) minus 119 (equal to 77 hex) equals 9.
  91.  
  92. The checksum is followed by the end-of-exclusive byte F7. Our entire message would be:
  93.  
  94. F0 41 10 42 12 40 01 30 06 09 F7
  95.  
  96. For the Sound Canvas, there is a slight variation on this message format when we want to address 
  97. parameters for a single part. Look in the Patch Parameter addresses in the manual to find: 
  98.  
  99. 40   1n   02   Rx Channel
  100. 40   1n   03   Rx Pitch-Bend
  101.  
  102. Notice all the addresses past this point have an "n" in the second address byte. In hex, the 16 Sound 
  103. Canvas parts are numbered starting with 1. For part 1, n=1, for part 2, n=2,  and so on. For part 10, n=0, 
  104. after which part 11 is numbered A and so on. For this example, let's say we want to change part 1 from 
  105. MIDI channel 1 to channel 16, and not have it respond to pitch-bend messages. First, we use the same 
  106. five-byte header, followed by the appropriate starting address as shown in the Patch Paramater list -- with 
  107. n=part 1 -- and two data bytes, since we're changing two consecutive parameters:
  108.  
  109. Header     F0  41  10  42  12    
  110. Address    40  11  02    
  111. Data       0F  00
  112.  
  113. Our checksum for this message would be:
  114.  
  115. 80 - (40 + 11 + 02 + 0F + 00) = Checksum
  116. 80 - 62 = Checksum
  117. 1E = Checksum
  118.  
  119. Yielding:
  120.  
  121. F0 41 10 42 12 40 11 02 0F 00 1E F7
  122.  
  123. Give these examples a try. With a little practice you too can become an official "hexhead."                   
  124.